package com.oa.system.entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.oa.organization.entity.Organization;

@Entity
@Table(name = "t_userinfo")
public class UserInfo {
	@Id
	@Column(nullable = false)
	private Long id;
	@Column(nullable = false, unique = true, length = 32)
	private String fullname;
	@Enumerated(EnumType.STRING)
	@Column(length = 8)
	private Sex sex;
	private int age;
	@JsonFormat(pattern = "yyyy/MM/dd", timezone = "GMT+8")
	private Date birthday;
	@Column(nullable = false, length = 128)
	private String email;
	@Column(length = 11)
	private String phone;
	private String address;
	@Column(length = 40)
	private String cover; // 用户头像
	@ManyToOne(cascade = CascadeType.ALL)
	@JoinColumn(name = "o_id")
	private Organization dept; // 部门
	private String job; // 职位
	@JsonFormat(pattern = "yyyy/MM/dd", timezone = "GMT+8")
	private Date enterTime; // 入职日期
	@ManyToOne(cascade = CascadeType.ALL)
	@JoinColumn(name = "r_id")
	private Role role;

	public enum Sex {
		male, female
	}

	public UserInfo() {
	}

	public Long getId() {
		return id;
	}

	public Sex getSex() {
		return sex;
	}

	public int getAge() {
		return age;
	}

	public Date getBirthday() {
		return birthday;
	}

	public String getEmail() {
		return email;
	}

	public String getPhone() {
		return phone;
	}

	public String getAddress() {
		return address;
	}

	public String getCover() {
		return cover;
	}

	public Organization getDept() {
		return dept;
	}

	public String getJob() {
		return job;
	}

	public Date getEnterTime() {
		return enterTime;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getFullname() {
		return fullname;
	}

	public void setFullname(String fullname) {
		this.fullname = fullname;
	}

	public void setSex(Sex sex) {
		this.sex = sex;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public void setCover(String cover) {
		this.cover = cover;
	}

	public void setDept(Organization dept) {
		this.dept = dept;
	}

	public void setJob(String job) {
		this.job = job;
	}

	public void setEnterTime(Date enterTime) {
		this.enterTime = enterTime;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	@Override
	public String toString() {
		return "UserInfo [id=" + id + ", fullname=" + fullname + ", sex=" + sex + ", age=" + age + ", birthday="
				+ birthday + ", email=" + email + ", phone=" + phone + ", address=" + address + ", cover=" + cover
				+ ", job=" + job + ", enterTime=" + enterTime + "]";
	}

}
